﻿namespace vkUpploaderLib
{
    using System.Collections.Generic;
    using System.Xml.Linq;

    using vkUpploaderLib.Objects;

    public static class GroupsHelper
    {
        public static List<VkGroup> Parse(XElement root)
        {
            List<VkGroup> result = new List<VkGroup>();

            foreach (XElement element in root.Elements())
            {
                if (element.Name != "group")
                {
                    continue;
                }

                VkGroup group = new VkGroup();
                group.Name = element.Element(XName.Get("name")).Value;
                group.Id = element.Element(XName.Get("gid")).Value;
                result.Add(group);
            }

            return result;
        }
    }
}